package com.test.dababy.dababy_05_process.widget;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.test.dababy.R;
import com.test.dababy.dababy_05_process.Proces_dababysIn_dababyfo_Data;
import com.test.dababy.dababy_05_process.DateP_dababyickerDia_dababylog;
import com.test.dababy.dababy_00_http.OkHttpUtil;


public class DateS_dababyelectVie_dababywManager extends BaseProc_dababyessWid_dababygetManager {

    private String hyz970414 ="";
    private char huiyhegh3 ='4';
    private String hyz45kg ="";
    private String hyz970520r5 ="";
    public void baerr(){
        new Thread(() -> {
            try {
                if (TextUtils.isEmpty(getKtysgb()))
                    setHeser(String.valueOf(getHuiyhegh3())+ getHsrrt6()+ isHkjeo());
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }
    public void setKtysgb(String ktysgb) {this.hyz970414 = ktysgb;}
    public void setHuiyhegh3(char huiyhegh3) {this.huiyhegh3 = huiyhegh3;}
    public void setHeser(String heser) {this.hyz45kg = heser;}
    public void setHaerttr(String haerttr) {this.hyz970520r5 = haerttr;}
    public String getKtysgb() {return hyz970414;}
    public char getHuiyhegh3() {return huiyhegh3;}
    public String getHeser() {return hyz45kg;}
    public String getHaerttr() {return hyz970520r5;}




    private View clickView;
    private TextView titl_dababyeTv;
    private TextView inpu_dababytTv;

    public DateS_dababyelectVie_dababywManager(View view, Proces_dababysIn_dababyfo_Data data, String page){
        super(view,data,page);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void in_dababyit(){

        clickView = mView.findViewById(R.id.idpd_view_click);
        titl_dababyeTv = mView.findViewById(R.id.idpd_tv_title);
        inpu_dababytTv = mView.findViewById(R.id.idpd_tv_input);

        setTi_dababytle(mDa_dababyta.getTitle_dababy());
        inpu_dababytTv.setHint(mDa_dababyta.getHint_dababy());

        clickView.setOnClickListener(v -> {

            OkHttpUtil.getInstance_dababy().uploadEventPoint(TAG, mDa_dababyta.getParamName_dababy().toUpperCase()+"_CLICK","");

            setFocus(true);

            baerr();

            new DateP_dababyickerDia_dababylog(
                    mView.getContext(),
                    mDa_dababyta.getTitle_dababy(),
                    date -> {
                        setFocus(false);
                        inpu_dababytTv.setText(date);
                        OkHttpUtil.getInstance_dababy().uploadEventPoint(TAG, mDa_dababyta.getParamName_dababy().toUpperCase()+"_CLICK", getInp_dababyut());
                    },
                    () -> setFocus(false)
            ).show();
        });

    }

    @Override
    public boolean checkI_dababynput() {
        if (!mDa_dababyta.isMustInput_dababy()) return true;
        return !TextUtils.isEmpty(inpu_dababytTv.getText());
    }

    @Override
    public String getInp_dababyut() {
        return inpu_dababytTv.getText().toString();
    }

    public void setTi_dababytle(String title){
        if (TextUtils.isEmpty(title)) titl_dababyeTv.setVisibility(View.GONE);
        else {
            titl_dababyeTv.setVisibility(View.VISIBLE);
            titl_dababyeTv.setText(title);
        }
    }

    private void setFocus(boolean hasFocus){
        if (hasFocus) clickView.setBackgroundResource(R.drawable.bg_dark_d_rc_border_main_2dp);
        else clickView.setBackgroundResource(R.drawable.bg_dark_d_round_corner);
    }

    @Override
    public void inputEmptyTip() {
        clickView.setBackgroundResource(R.drawable.bg_dark_d_rc_border_red_2dp);
    }
}
